package com.threadmethod.wait;

/**
 * @PackageName:com.threadmethod.wait
 * @ClassName:Test07
 * @Description: wait(long)
 * @Author: zhangxiaoyu
 * @date 2021/1/11 17:08
 */
public class Test07 {

    public static void main(String[] args){

        final Object obj = new Object();

         Thread  t = new Thread(new Runnable() {
             @Override
             public void run() {
                 synchronized (obj){
                     try {
                         System.out.println("start");
                         obj.wait(5000); //如果5000毫秒内没有被唤醒 会自动唤醒
                         System.out.println("end");
                     } catch (InterruptedException e) {
                         e.printStackTrace();
                     }
                 }
            
             }
         });
         t.start();
    }

}
